TINGZHI_FLAG_PATH = "task_file/tingzhi_flag"
from chengxu.robot_control import *
from chengxu.main_module import VoiceModule, DisplayModule,CameraModule

import sys

# 初始化语音和显示模块
voice_module = VoiceModule()
display_module = DisplayModule()

def tuichu():
    stopRobot()
    '''if hasattr(camera, 'cap') and camera.cap.isOpened():
        camera.cap.release()'''
    
    sys.exit(0)
    '''with open(TINGZHI_FLAG_PATH, "r") as f:
        if f.read().strip() == "True":
            print("检测到停止信号，程序退出")
            stopRobot()
            sys.exit(0)'''

def bobaowenjian():
    """从文件读取内容并播报"""
    try:
        with open("task_file/tzrweml/T2DA.txt", "r", encoding="utf-8") as file:
            content = file.read().strip()
        display_module.display_text_and_play_audio(content, voice_module)
    except Exception as e:
        print(f"读取或播报文件时出错: {str(e)}")
        # 如果读取失败，使用默认内容
        display_module.display_text_and_play_audio("任务完成", voice_module)


